$(document).ready(function () {

    $("#query").click(function () {
        const name = $("#name").val();
        const temp_exam = $("input[name='make_up_exam']:checked").val();
        let make_up_exam = temp_exam? temp_exam: false;
        let url = window.location.href.split('?')[0];
        // 此处是为了兼容之前的版本，teacher为/就可进入的版本
        if(url[url.length - 1] !== '/') {
            url += '/';
        }
        console.log('the url is : ', url);
        console.log('make_up_exam: ', make_up_exam);
        $.ajax({
            url: url,
            async: true,
            type: "POST",
            dataType: "JSON",
            data: {
                name: name,
            },
            success: function (res) {
                console.log('the res is ',res);
                const teacher_list = res;
                $('#select_list').empty('p');
                $.each(teacher_list, function (i, item) {
                    $('#select_list')
                        .append(
                            '<p>' +
                            '<a class="select_a"  ' +
                            'href = ' +
                            url + 'getTestByName?' +
                            'name=' + item +
                            '&make_up_exam=' + make_up_exam
                            + ' >' +
                            item + '' +
                            '</a>' +
                            '</p>')
                })
            }, fail: err => {
                console.log('出错了, err = ' + err + "jsonErr = " + JSON.stringify(err))
            }

        })
    });

});